<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<shiro:hasPermission name="appversion:select">
	<div class="content1">
		<div class="header">
			<h1 class="page-title">app更新检查</h1>
			<ul class="breadcrumb">
				<li>app更新检查</li>
				<li class="active">app更新检查</li>
			</ul>
		</div>
		<div class="main-content">
			<div class="row">
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">APP类型</div>
							<select class="form-control" id="appType">
							<option value="">请选择</option>
							  <option value="1">ios</option>
							  <option value="0">android</option>
							  <option value="2">wp</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">状态</div>
							<select class="form-control" id="state">
							<option value="">请选择</option>
							  <option value="1">开启</option>
							  <option value="0">关闭</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<button type="button" class="btn btn-primary btn-small btn-block"
						id="query">
						<i class="glyphicon glyphicon-search"></i> 查询
					</button>
				</div>
				
				<div class="col-md-2">
					<shiro:hasPermission name="appversion:add">
						<button type="button" class="btn btn-info btn-small btn-block"
							onclick="addAndUpdateRow(0)">
							<i class="glyphicon glyphicon-plus"></i> 增加
						</button>
					</shiro:hasPermission>
				</div>
			</div>
			<table id="example" class="table"></table>
		</div>
		<script>
			//表格的初始化
			$(document).ready(function() {
				var table = $('#example').initTable({
					sAjaxSource:"appversion/initTable.htm",
					aoColumns: [
			             { 
			                "data": "appType",
			                "sTitle":"APP类型",
			                'sClass':"text-center",
			                "mRender": function(data, type, full) { 
			                	if(data == 1){
									return "<font color='red'>ios</font>";
								}else if(data == 0){
									return "<font color='red'>android</font>";
								}else if(data == 2){
									return "<font color='red'>wp</font>";
								}else{
									return "<font color='red'>未知</font>";
								}
			                } 
			             },
			            { 
			                "data": "versionNumber",
			                "sTitle":"版本号",
			                'sClass':"text-center"
			            },
			            { 
			                "data": "state",
			                "sTitle":"状态",
			                'sClass':"text-center",
			                "mRender": function(data, type, full) { 
			                	if(data == 1){
									return "<font color='red'>有效</font>";
								}else if(data == 2){
									return "<font color='red'>失效</font>";
								}else if(data == 9){
									return "<font color='red'>已刪除</font>";
								}
			                } 
			            },
			            { 
			                "data": "createTime",
			                "sTitle":"创建时间",
			                'sClass':"text-center"
			            },
			            { 
			                "data": "updateTime",
			                "sTitle":"更新时间",
			                'sClass':"text-center"
			            },
			            { 
			            	"data": "downloadUrl",
			            	"sTitle":"下载地址",
			            	'sClass':"text-center"
			            },
			            { 
			            	"data": "remark",
			            	"sTitle":"备注",
			            	'sClass':"text-center"
			            },
			            <shiro:hasPermission name="appversion:update or appversion:delete">
			           	 	{"data": "appversionId","sTitle":"操作",'sClass':"text-center"}
			            </shiro:hasPermission>
			         ],
					 fnServerParams: function (aoData) {  //查询条件
		             	aoData.push({ "name": "appType", "value": $("#appType").val() } );
		             	aoData.push({ "name": "state", "value": $("#state").val() } );
		             },
		             aoColumnDefs : [
							<shiro:hasPermission name="appversion:update or appversion:delete">
								{"aTargets" :7,"mRender" : function(data, type, row){
										var edit="",del="";
											<shiro:hasPermission name="appversion:update">
					             				edit = "<a href='#' onclick='addAndUpdateRow(\""+data+"\")' data-toggle='modal' class='padding-right-small label label-success'><i class='glyphicon glyphicon-edit'></i> 编辑</a>";
					             			</shiro:hasPermission>
			 		                    return edit+"&nbsp;"+del;
									}
								}
							</shiro:hasPermission>
		     			]
				});
				
				 $('#query').click(function(){
					$('#example').dataTable().fnDraw();
				});
			});
			//删除受影响的行数
			function deleteRow(id){
				console.log(id);
				alert(id);
				$('#myModal').deleteRow('appversion/del.htm?id='+id);
			}
			//增加或者修改受影响的行数
			function addAndUpdateRow(id){
				$('#insertAndUpdate').addAndUpdateRow("appversion/addAndUpdateHome.htm?id="+id);
			}
			</script>
		<!---dialog选项-->
		<div>
			<jsp:include page="/WEB-INF/views/common/delete_dialog.jsp" />
			<jsp:include page="/WEB-INF/views/common/addupdate_dialog.jsp" />
	
			<div class="modal fade" id="insertAndUpdate" tabindex="-1"
				role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			</div>
		</div>
	</div>
</shiro:hasPermission>